import { app } from "../../../config/index"

Page({
  data: {
    nameValue: '',
  },
  onLoad() {
    this.setData({
      nameValue: app.globalData.userInfo.nickName,
    });
  },
  onSubmit() {
    wx.cloud.database().collection("book-user").where({
      _id: app.globalData.userInfo._id
    }).update({
      data:{
        nickName: this.data.nameValue,
        _updateTime: Date.now(),
      },
      success:(res)=>{
        app.globalData.userInfo.nickName = this.data.nameValue
        wx.navigateBack({ backRefresh: true });
      },
    })
  },
  clearContent() {
    this.setData({
      nameValue: '',
    });
  },
});
